package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.pojo.DocumentInfoRequest;
import cn.stylefeng.guns.modular.business.service.DocumentInfoService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 文献信息表控制器
 *
 * @author zhangyaowen
 * @date 2021/10/28 16:51
 */
@RestController
@ApiResource(name = "文献信息表")
public class DocumentInfoController {

    @Resource
    private DocumentInfoService documentInfoService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/10/28 16:51
     */
    @PostResource(name = "添加", path = "/documentInfo/add")
    public ResponseData add(@RequestBody @Validated(DocumentInfoRequest.add.class) DocumentInfoRequest documentInfoRequest) {
        documentInfoService.add(documentInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/10/28 16:51
     */
    @PostResource(name = "删除", path = "/documentInfo/delete")
    public ResponseData delete(@RequestBody @Validated(DocumentInfoRequest.delete.class) DocumentInfoRequest documentInfoRequest) {
        documentInfoService.del(documentInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/10/28 16:51
     */
    @PostResource(name = "编辑", path = "/documentInfo/edit")
    public ResponseData edit(@RequestBody @Validated(DocumentInfoRequest.edit.class) DocumentInfoRequest documentInfoRequest) {
        documentInfoService.edit(documentInfoRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/10/28 16:51
     */
    @GetResource(name = "查看详情", path = "/documentInfo/detail")
    public ResponseData detail(@Validated(DocumentInfoRequest.detail.class) DocumentInfoRequest documentInfoRequest) {
        return new SuccessResponseData(documentInfoService.detail(documentInfoRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/10/28 16:51
     */
    @GetResource(name = "获取列表", path = "/documentInfo/list")
    public ResponseData list(DocumentInfoRequest documentInfoRequest) {
        return new SuccessResponseData(documentInfoService.findList(documentInfoRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/10/28 16:51
     */
    @GetResource(name = "分页查询", path = "/documentInfo/page")
    public ResponseData page(String year ,String value) {

        return new SuccessResponseData(documentInfoService.findPage(year,value));
    }

    @GetResource(name = "详细信息", path = "/documentInfo/toReview")
    public ResponseData toReview(String id) {

        return new SuccessResponseData(documentInfoService.toReview(id));
    }

}